<?php

namespace IDock\Insurance\TPBX\Request;

use IDock\Http\RequestFormat;
use IDock\Insurance\TPBX\Request\AllTPBXRequest;
use IDock\Insurance\TPBX\Response\EPolicyDownloadResponse;
use IDock\Visitor\EPolicyDownloadVisitor;

class EPolicyDownloadRequest extends AllTPBXRequest
{
    public $route = 'webapi/v1/url/printUrl';

    public $requestType = 'V113';

    protected $response = EPolicyDownloadResponse::class;

    protected $urlTip = '下载电子保单';

    /**
     * @var  EPolicyDownloadVisitor $visitor
     */
    protected $visitor;

    public function generate(): array
    {
        $policy = $this->visitor->policyNo;
        $arr = [
            'basePart' => [
                'policyNo' => $policy,
                'printType' => '2',//2-电子保单
            ],
        ];
        if(substr($policy,8,3) == '718'){
            $arr['basePart']['printType'] = '5';
        }
        if(isset($this->visitor->argc['printType'])){
            $arr['basePart']['printType'] = '4';//交强险标志
        }
        return $arr;
    }
}
